import { createChunk } from './createChunk';

onmessage = async (e) => {
  const { file, start, end, CHUNK_SIZE } = e.data;
  console.log(file);
  const result = [];
  // 开始分片
  for (let i = start; i < end; i++) {
    const promise = createChunk(file, i, CHUNK_SIZE);
    result.push(promise);
  }

  const chunks = await Promise.all(result);
  // 将结果弄出去
  postMessage(chunks);
};
